<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html   xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Add user page</title>
    </h:head>
    <h:body>
          <h:form>
            <h:panelGrid columns="3" cellpadding="5">
                <p:outputLabel for="loginArea" 
                               value="#{bundle.login}: " />
                <p:inputText id="loginArea" 
                             value="#{addUserController.login}"
                             required="true">
                    <f:validateLength minimum="3" maximum="30"/>
                    <f:validateRegex pattern="^([a-zA-Z0-9]{3,30})$"/>
                </p:inputText>
                <h:message for="loginArea"/>
          
                <p:outputLabel for="passwordArea" 
                               value="#{bundle.password}: " />
                <p:password id="passwordArea" 
                               value="#{addUserController.password}"
                             required="true">
                    <f:validateLength minimum="3" maximum="30"/>
                </p:password>
                <h:message for="passwordArea"/>
          
                <p:outputLabel for="passwordConfArea" 
                               value="#{bundle.password_confirm}: " />
                <p:password id="passwordConfArea" 
                            value="#{addUserController.passwordConfirm}"
                            required="true">
                    <f:validateLength minimum="3" maximum="30"/>
                </p:password>
                <h:message for="passwordConfArea"/>
                
                <p:outputLabel for="nameArea" 
                               value="#{bundle.name}: " />
                <p:inputText id="nameArea" 
                             value="#{addUserController.name}"
                             required="true">
                    <f:validateLength minimum="1" maximum="30"/>
                </p:inputText>
                <h:message for="nameArea"/>
                
                 <p:outputLabel for="surnameArea" 
                               value="#{bundle.surname}: " />
                <p:inputText id="surnameArea" 
                             value="#{addUserController.surname}"
                             required="true">
                    <f:validateLength minimum="1" maximum="30"/>
                </p:inputText>
                <h:message for="surnameArea"/>
 
                <p:outputLabel for="phoneArea" value="#{bundle.phone}: " />
                <p:inputMask id="phoneArea" 
                             value="#{addUserController.telephone}" 
                       mask="(999) 999-9999"
                       required="true">
                </p:inputMask>
                <h:message for="phoneArea"/>
          
                <p:outputLabel for="emailArea" value="#{bundle.email}: " />
                <p:inputText id="emailArea" 
                             value="#{addUserController.email}"
                       required="true">
                    <f:validateRegex 
                        pattern="^[_a-z0-9]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[_a-z0-9-]+)*(\.[a-z]{2,4})$"/>
                </p:inputText>
                <h:message for="emailArea"/>
                
            </h:panelGrid>
              
                <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
                    <p:outputLabel for="role" value="Role:" />
                    <p:selectOneRadio id="role" 
                                      value="#{addUserController.role}">
                        <f:selectItem itemLabel="#{bundle.administrator}" 
                                      itemValue="admin" />
                        <f:selectItem itemLabel="#{bundle.employee}" 
                                      itemValue="employee" />
                        <f:selectItem itemLabel="#{bundle.client}" 
                                      itemValue="client" />
                        <f:selectItem itemLabel="#{bundle.manager}" 
                                      itemValue="manager" />
                    </p:selectOneRadio>
                </h:panelGrid>
                
            <h:panelGrid>
                 <p:commandButton id="addUserButton" 
                      value="#{bundle.add_user}"
                      action="#{addUserController.addUser()}"/>
            </h:panelGrid>
          </h:form>
    </h:body>
</html>

